home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / gridex / frmsuppl.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-01-02  |  12.8 KB  |  408 lines

  1. VERSION 5.00
  2. Begin VB.Form frmSuppliers 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Suppliers"
  5.    ClientHeight    =   5085
  6.    ClientLeft      =   960
  7.    ClientTop       =   2490
  8.    ClientWidth     =   7560
  9.    BeginProperty Font 
  10.       Name            =   "Tahoma"
  11.       Size            =   8.25
  12.       Charset         =   0
  13.       Weight          =   400
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    Icon            =   "frmSuppliers.frx":0000
  19.    LinkTopic       =   "Form1"
  20.    MaxButton       =   0   'False
  21.    MinButton       =   0   'False
  22.    ScaleHeight     =   339
  23.    ScaleMode       =   3  'Pixel
  24.    ScaleWidth      =   504
  25.    StartUpPosition =   2  'CenterScreen
  26.    Begin VB.TextBox txtField 
  27.       Height          =   345
  28.       Index           =   3
  29.       Left            =   5130
  30.       TabIndex        =   4
  31.       Top             =   1485
  32.       Width           =   2340
  33.    End
  34.    Begin VB.CommandButton cmdCancel 
  35.       Cancel          =   -1  'True
  36.       Caption         =   "Cancel"
  37.       Height          =   360
  38.       Left            =   3810
  39.       TabIndex        =   13
  40.       Top             =   4635
  41.       Width           =   1200
  42.    End
  43.    Begin VB.CommandButton cmdOK 
  44.       Caption         =   "OK"
  45.       Default         =   -1  'True
  46.       Height          =   360
  47.       Left            =   2505
  48.       TabIndex        =   12
  49.       Top             =   4635
  50.       Width           =   1200
  51.    End
  52.    Begin VB.TextBox txtField 
  53.       Height          =   720
  54.       Index           =   4
  55.       Left            =   1320
  56.       MultiLine       =   -1  'True
  57.       TabIndex        =   5
  58.       Top             =   1905
  59.       Width           =   6180
  60.    End
  61.    Begin VB.TextBox txtField 
  62.       Height          =   345
  63.       Index           =   9
  64.       Left            =   5040
  65.       TabIndex        =   11
  66.       Top             =   3765
  67.       Width           =   2400
  68.    End
  69.    Begin VB.ComboBox cboCountry 
  70.       Height          =   315
  71.       Left            =   5040
  72.       TabIndex        =   9
  73.       Top             =   3315
  74.       Width           =   2400
  75.    End
  76.    Begin VB.TextBox txtField 
  77.       Height          =   345
  78.       Index           =   6
  79.       Left            =   5040
  80.       TabIndex        =   7
  81.       Top             =   2850
  82.       Width           =   2400
  83.    End
  84.    Begin VB.TextBox txtField 
  85.       Height          =   345
  86.       Index           =   8
  87.       Left            =   1305
  88.       TabIndex        =   10
  89.       Top             =   3720
  90.       Width           =   2400
  91.    End
  92.    Begin VB.TextBox txtField 
  93.       Height          =   345
  94.       Index           =   7
  95.       Left            =   1305
  96.       TabIndex        =   8
  97.       Top             =   3255
  98.       Width           =   2400
  99.    End
  100.    Begin VB.TextBox txtField 
  101.       Height          =   345
  102.       Index           =   5
  103.       Left            =   1305
  104.       TabIndex        =   6
  105.       Top             =   2820
  106.       Width           =   2400
  107.    End
  108.    Begin VB.TextBox txtField 
  109.       Height          =   345
  110.       Index           =   2
  111.       Left            =   1305
  112.       TabIndex        =   3
  113.       Top             =   1485
  114.       Width           =   3150
  115.    End
  116.    Begin VB.TextBox txtField 
  117.       Height          =   345
  118.       Index           =   1
  119.       Left            =   1305
  120.       TabIndex        =   1
  121.       Top             =   1080
  122.       Width           =   6180
  123.    End
  124.    Begin VB.TextBox txtField 
  125.       Height          =   345
  126.       Index           =   0
  127.       Left            =   1320
  128.       Locked          =   -1  'True
  129.       TabIndex        =   0
  130.       Top             =   660
  131.       Width           =   1485
  132.    End
  133.    Begin VB.Image Image1 
  134.       Height          =   480
  135.       Left            =   105
  136.       Picture         =   "frmSuppliers.frx":030A
  137.       Top             =   15
  138.       Width           =   480
  139.    End
  140.    Begin VB.Label lblName 
  141.       Alignment       =   1  'Right Justify
  142.       BackColor       =   &H80000003&
  143.       Caption         =   "Suppliers "
  144.       BeginProperty Font 
  145.          Name            =   "Tahoma"
  146.          Size            =   18
  147.          Charset         =   0
  148.          Weight          =   700
  149.          Underline       =   0   'False
  150.          Italic          =   0   'False
  151.          Strikethrough   =   0   'False
  152.       EndProperty
  153.       ForeColor       =   &H8000000E&
  154.       Height          =   540
  155.       Left            =   -75
  156.       TabIndex        =   24
  157.       Top             =   0
  158.       Width           =   7635
  159.    End
  160.    Begin VB.Label lblField 
  161.       AutoSize        =   -1  'True
  162.       Caption         =   "Title:"
  163.       Height          =   195
  164.       Index           =   2
  165.       Left            =   4710
  166.       TabIndex        =   23
  167.       Top             =   1560
  168.       Width           =   360
  169.    End
  170.    Begin VB.Line Line1 
  171.       BorderColor     =   &H80000014&
  172.       Index           =   1
  173.       X1              =   -2
  174.       X2              =   503
  175.       Y1              =   300
  176.       Y2              =   300
  177.    End
  178.    Begin VB.Line Line1 
  179.       BorderColor     =   &H80000010&
  180.       Index           =   0
  181.       X1              =   -2
  182.       X2              =   503
  183.       Y1              =   299
  184.       Y2              =   299
  185.    End
  186.    Begin VB.Label lblField 
  187.       AutoSize        =   -1  'True
  188.       Caption         =   "Address:"
  189.       Height          =   195
  190.       Index           =   4
  191.       Left            =   600
  192.       TabIndex        =   22
  193.       Top             =   1965
  194.       Width           =   645
  195.    End
  196.    Begin VB.Label lblField 
  197.       AutoSize        =   -1  'True
  198.       Caption         =   "Fax:"
  199.       Height          =   195
  200.       Index           =   10
  201.       Left            =   4320
  202.       TabIndex        =   21
  203.       Top             =   3810
  204.       Width           =   330
  205.    End
  206.    Begin VB.Label lblField 
  207.       AutoSize        =   -1  'True
  208.       Caption         =   "Phone:"
  209.       Height          =   195
  210.       Index           =   9
  211.       Left            =   735
  212.       TabIndex        =   20
  213.       Top             =   3795
  214.       Width           =   510
  215.    End
  216.    Begin VB.Label lblField 
  217.       AutoSize        =   -1  'True
  218.       Caption         =   "Country:"
  219.       Height          =   195
  220.       Index           =   8
  221.       Left            =   4005
  222.       TabIndex        =   19
  223.       Top             =   3345
  224.       Width           =   645
  225.    End
  226.    Begin VB.Label lblField 
  227.       AutoSize        =   -1  'True
  228.       Caption         =   "Postal Code:"
  229.       Height          =   195
  230.       Index           =   7
  231.       Left            =   330
  232.       TabIndex        =   18
  233.       Top             =   3330
  234.       Width           =   915
  235.    End
  236.    Begin VB.Label lblField 
  237.       AutoSize        =   -1  'True
  238.       Caption         =   "Region:"
  239.       Height          =   195
  240.       Index           =   6
  241.       Left            =   4095
  242.       TabIndex        =   17
  243.       Top             =   2895
  244.       Width           =   555
  245.    End
  246.    Begin VB.Label lblField 
  247.       AutoSize        =   -1  'True
  248.       Caption         =   "City:"
  249.       Height          =   195
  250.       Index           =   5
  251.       Left            =   900
  252.       TabIndex        =   16
  253.       Top             =   2880
  254.       Width           =   345
  255.    End
  256.    Begin VB.Label lblField 
  257.       AutoSize        =   -1  'True
  258.       Caption         =   "Contact Name:"
  259.       Height          =   195
  260.       Index           =   3
  261.       Left            =   165
  262.       TabIndex        =   15
  263.       Top             =   1560
  264.       Width           =   1080
  265.    End
  266.    Begin VB.Label lblField 
  267.       AutoSize        =   -1  'True
  268.       Caption         =   "Company Name:"
  269.       Height          =   195
  270.       Index           =   1
  271.       Left            =   60
  272.       TabIndex        =   14
  273.       Top             =   1125
  274.       Width           =   1185
  275.    End
  276.    Begin VB.Label lblField 
  277.       AutoSize        =   -1  'True
  278.       Caption         =   "Supplier ID:"
  279.       Height          =   195
  280.       Index           =   0
  281.       Left            =   405
  282.       TabIndex        =   2
  283.       Top             =   735
  284.       Width           =   840
  285.    End
  286. Attribute VB_Name = "frmSuppliers"
  287. Attribute VB_GlobalNameSpace = False
  288. Attribute VB_Creatable = False
  289. Attribute VB_PredeclaredId = True
  290. Attribute VB_Exposed = False
  291. Option Explicit
  292. Dim m_db As Database
  293. Dim mrstSuppliers As Recordset
  294. Dim mvarBookmark As Variant
  295. Dim mbIsNew As Boolean
  296. Public Key As String
  297. Private Const fldSupplierID = 0
  298. Private Const fldCompanyName = 1
  299. Private Const fldContactName = 2
  300. Private Const fldContactTitle = 3
  301. Private Const fldAddress = 4
  302. Private Const fldCity = 5
  303. Private Const fldRegion = 6
  304. Private Const fldPostalCode = 7
  305. Private Const fldPhone = 8
  306. Private Const fldFax = 9
  307. Private Const fldCountry = 10
  308. Dim m_DataChanged(10) As Boolean
  309. Public Sub EditRecord(db As Database, rs As Recordset)
  310. Dim rstCountry As Recordset
  311. Dim i As Long
  312. On Error Resume Next
  313.     Set m_db = db
  314.     Set mrstSuppliers = rs.Clone
  315.     mvarBookmark = rs.Bookmark
  316.     mrstSuppliers.Bookmark = mvarBookmark
  317.     Set rstCountry = m_db.OpenRecordset("SELECT DISTINCT Suppliers.Country FROM Suppliers ORDER BY Suppliers.Country", dbOpenSnapshot)
  318.     cboCountry.Clear
  319.     cboCountry.AddItem ""
  320.     Do Until rstCountry.EOF
  321.         cboCountry.AddItem rstCountry![Country]
  322.         rstCountry.MoveNext
  323.     Loop
  324.     txtField(fldSupplierID).Text = mrstSuppliers![SupplierID]
  325.     txtField(fldCompanyName).Text = mrstSuppliers![CompanyName]
  326.     txtField(fldContactName).Text = mrstSuppliers![ContactName]
  327.     txtField(fldContactTitle).Text = mrstSuppliers![ContactTitle]
  328.     txtField(fldAddress).Text = mrstSuppliers![Address]
  329.     txtField(fldCity).Text = mrstSuppliers![City]
  330.     txtField(fldRegion).Text = mrstSuppliers![Region]
  331.     txtField(fldPostalCode).Text = mrstSuppliers![PostalCode]
  332.     txtField(fldPhone).Text = mrstSuppliers![Phone]
  333.     txtField(fldFax).Text = mrstSuppliers![Fax]
  334.     cboCountry.Text = mrstSuppliers![Country]
  335.     Caption = "Suppliers - " & mrstSuppliers![CompanyName]
  336.     For i = 0 To UBound(m_DataChanged)
  337.         m_DataChanged(i) = False
  338.     Next
  339.         
  340.     Me.Show
  341. End Sub
  342. Public Sub NewRecord(db As Database, rs As Recordset)
  343. Dim rstCountry As Recordset
  344. Dim i As Long
  345. On Error Resume Next
  346.     Set m_db = db
  347.     Set mrstSuppliers = rs.Clone
  348.     mbIsNew = True
  349.     mvarBookmark = Null
  350.     Set rstCountry = m_db.OpenRecordset("SELECT DISTINCT Suppliers.Country FROM Suppliers ORDER BY Suppliers.Country", dbOpenSnapshot)
  351.     cboCountry.Clear
  352.     cboCountry.AddItem ""
  353.     Do Until rstCountry.EOF
  354.         cboCountry.AddItem rstCountry![Country]
  355.         rstCountry.MoveNext
  356.     Loop
  357.     Caption = "Suppliers - " & mrstSuppliers![CompanyName]
  358.     Me.Show
  359. End Sub
  360. Private Sub cboCountry_Click()
  361.     m_DataChanged(fldCountry) = True
  362. End Sub
  363. Private Sub cboCountry_Change()
  364.     m_DataChanged(fldCountry) = True
  365. End Sub
  366. Private Sub cmdCancel_Click()
  367.     Unload Me
  368. End Sub
  369. Private Sub cmdOK_Click()
  370. On Error GoTo EH_cmdOK
  371. Dim bUpdate As Boolean
  372. Dim i As Integer
  373.     For i = 0 To UBound(m_DataChanged)
  374.         If m_DataChanged(i) Then bUpdate = True
  375.     Next
  376.     If bUpdate Then
  377.         If mbIsNew Then
  378.             mrstSuppliers.AddNew
  379.         Else
  380.             mrstSuppliers.Edit
  381.         End If
  382.         If m_DataChanged(fldSupplierID) Then mrstSuppliers![SupplierID] = txtField(fldSupplierID)
  383.         If m_DataChanged(fldCompanyName) Then mrstSuppliers![CompanyName] = txtField(fldCompanyName)
  384.         If m_DataChanged(fldContactName) Then mrstSuppliers![ContactName] = txtField(fldContactName)
  385.         If m_DataChanged(fldContactTitle) Then mrstSuppliers![ContactTitle] = txtField(fldContactTitle)
  386.         If m_DataChanged(fldAddress) Then mrstSuppliers![Address] = txtField(fldAddress)
  387.         If m_DataChanged(fldCity) Then mrstSuppliers![City] = txtField(fldCity)
  388.         If m_DataChanged(fldRegion) Then mrstSuppliers![Region] = txtField(fldRegion)
  389.         If m_DataChanged(fldPostalCode) Then mrstSuppliers![PostalCode] = txtField(fldPostalCode)
  390.         If m_DataChanged(fldPhone) Then mrstSuppliers![Phone] = txtField(fldPhone)
  391.         If m_DataChanged(fldFax) Then mrstSuppliers![Fax] = txtField(fldFax)
  392.         If m_DataChanged(fldCountry) Then mrstSuppliers![Country] = cboCountry.Text
  393.         mrstSuppliers.Update
  394.         Hide
  395.         frmMain.OnRecordUpdate CatalogSuppliers, mvarBookmark
  396.     End If
  397.     Unload Me
  398.     Exit Sub
  399. EH_cmdOK:
  400.     MsgBox Err.Description
  401. End Sub
  402. Private Sub Form_Unload(Cancel As Integer)
  403.     frmMain.UnloadForm Key
  404. End Sub
  405. Private Sub txtField_Change(Index As Integer)
  406.     m_DataChanged(Index) = True
  407. End Sub
  408.